<script>
	$(function() {
		$("#uploadFiles").MultiFile({
			STRING: {
			file: '<em title="Click to remove" onclick="$(this).parent().prev().click()"><h3>$file</h3></em>',
			remove: '<img src="http://www.fyneworks.com/@/bin.gif" height="16" width="16" alt="X"/>'
			}
		});
		
		$("#cboCountry").change(function() { 
		/* do something here */ 
			var ajax_url = '../incs/list_school_by_country_id.php?qg_id='+ $("#cboCountry").val();
			$.get(ajax_url,function(data){
			$('#cboSchool').html(data);
			});
		});
		$("#cboSchool").change(function() { 
		/* do something here */ 
			var ajax_url = '../incs/list_dept_by_school_id.php?truong_id='+ $("#cboSchool").val();
			$.get(ajax_url,function(data){
			$('#cboDept').html(data);
			});
		});
		$("#cboCountry1").change(function() { 
		/* do something here */ 
			var ajax_url = '../incs/list_school_by_country_id.php?qg_id='+ $("#cboCountry1").val();
			$.get(ajax_url,function(data){
			$('#cboSchool1').html(data);
			});
		});
		$("#cboSchool1").change(function() { 
		/* do something here */ 
			var ajax_url = '../incs/list_dept_by_school_id.php?truong_id='+ $("#cboSchool1").val();
			$.get(ajax_url,function(data){
			$('#cboDept1').html(data);
			});
		});
		
		$("#cboDept1").change(function() { 
		/* do something here */ 
			var ajax_url = '../tac_gia/list_author_by_dept_id.php?dv_id='+ $("#cboDept1").val();
			$.get(ajax_url,function(data){
			$('#cboAuthor-Topic').html(data);
			});
		});
		/*$('#btnAddPeson').click(function() {
	  		if ($('#cboAuthor-Topic').val() == -1) event.preventDefault();
		});*/
		
		$("#txtNgaybatdau").datepicker({dateFormat: 'dd-mm-yy'});
		$("#txtNgayketthuc").datepicker({dateFormat: 'dd-mm-yy'});
		
		tinyMCE.init({
        // General options
        mode : "exact",
		elements : "mtxNoidung",
        theme : "advanced",
        plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template", 
 
        // Theme options 
        theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect", 
        theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", 
        theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", 
        theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage", 
        theme_advanced_toolbar_location : "top", 
        theme_advanced_toolbar_align : "left", 
        theme_advanced_statusbar_location : "bottom", 
        theme_advanced_resizing : true, 

// Skin options 
        skin : "o2k7", 
        skin_variant : "silver", 
 

 
        // Drop lists for link/image/media/template dialogs 
        template_external_list_url : "http://localhost/sam/src/library/plugin/tinymce/examples/lists/template_list.js", 
        external_link_list_url : "http://localhost/sam/src/library/plugin/tinymce/examples/lists/link_list.js", 
        external_image_list_url : "http://localhost/sam/src/library/plugin/tinymce/examples/lists/image_list.js", 
        media_external_list_url : "http://localhost/sam/src/library/plugin/tinymce/examples/lists/media_list.js", 

        // Replace values for the template plugin
        template_replace_values : {
                username : "Some User",
                staffid : "991234"
        }
});

	});
</script>

<?php
if (!defined('WEB_ROOT')) {
	exit;
}

$nn_id = (isset($_GET['nn_id']) && $_GET['nn_id'] > 0) ? $_GET['nn_id'] : 0;

$dv_id = (isset($_GET['dv_id']) && $_GET['dv_id'] > 0) ? $_GET['dv_id'] : 0;

$tennth = (isset($_GET['tennth']) && $_GET['tennth'] !='') ? $_GET['tennth'] : 'alpha';
  
$topicGroupList = buildTopicGroupOptions($nn_id);
$countryList = buildCountryOptions($qg_id);
$deptList = buildDeptOptions($dv_id);
$roleList = buildRoleOptions($vt_id);
$stateList = buildStateOptions($tt_id);
$levelList = buildLevelOptions($cap_id);
$proList = buildPropertyOptions($dtr_id);
$styleList = buildStyleTopicOptions($loaidt_id);
?> 
<div class="onecolumn">
		<div class="header">
				<span>Thêm đề tài</span>
		</div>
		<br class="clear"/>
		<div class="content">
				<form action="processTopic.php?action=addTopic" method="post" enctype="multipart/form-data" name="frmAddTopic" id="frmAddTopic">
				  <input name="tg" id="tg" type="hidden" />
				  <table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" class="entryTable">
				  <tr> 
					   <td width="150" class="label">Mã đề tài</td>
					   <td colspan="5" class="content"> <input name="txtMadt" type="text" class="box" id="txtMadt" size="20" maxlength="20"></td>
				  </tr>
				  <tr> 
					   <td width="150" class="label">Tên đề tài</td>
					   <td colspan="5" class="content"><textarea name="mxtTendt" cols="150" rows="2" class="box" id="mxtTendt"></textarea></td>
				  </tr>
				  <tr> 
					   <td width="150" class="label">Tóm tắt đề tài</td>
					   <td colspan="5" class="content"> <textarea name="mtxTomtat" mce_editable="false" cols="150" rows="4" class="box" id="mtxTomtat"></textarea></td>
				  </tr>
				  <tr> 
					   <td width="150" class="label">Năm thực hiện</td>
					   <td class="content" colspan="2"><input name="txtNamthuchien" type="text" id="txtNamthuchien" size="20" maxlength="20" class="box"> </td>
					   <td width="100" class="label">Ngày bắt đầu </td>
					   <td class="content" colspan="2"><input name="txtNgaybatdau" type="text" id="txtNgaybatdau" size="10" maxlength="10" class="box" />
					   &nbsp;&nbsp;&nbsp;&nbsp;Ngày kết thúc&nbsp;&nbsp;&nbsp;&nbsp;<input name="txtNgayketthuc" type="text" id="txtNgayketthuc" size="10" maxlength="10" class="box" /></td>
				  </tr>
				  <tr> 
					   <td width="150" class="label">Kinh phí</td>
					   <td class="content" colspan="2"> <input name="txtKinhphi" type="text" class="box" id="txtKinhphi" size="20" maxlength="20"></td>
					   <td width="100" class="label">Cấp thực hiện</td>
					   <td class="content"> <select name="cboLevel" id="cboLevel" class="box">
						<option value="" selected>-- Chọn cấp thực hiện --</option>
							<?php
								echo $levelList;
							?>	 
						</select></td></td>
				  </tr>
				  <tr>
				  	 <td width="150" class="label">Nhóm ngành</td>
					   <td class="content" colspan = "2"> <select name="cboTopicGroup" id="cboTopicGroup" class="box">
						<option value="" selected>-- Chọn nhóm ngành --</option>
							<?php
								echo $topicGroupList;
							?>	 
						</select></td>
						<td width="100" class="label">Trạng thái</td>
					   <td class="content"> <select name="cboState" id="cboState" class="box">
						<option value="" selected>-- Chọn trạng thái --</option>
							<?php
								echo $stateList;
							?>	 
						</select></td>
				  </tr>
				  <tr> 
					  
						<td width="150" class="label">Loại đề tài</td>
					   <td class="content" colspan="2"> <select name="cboStyleTopic" id="cboStyleTopic" class="box">
						<option value="" selected>-- Chọn loại đề tài --</option>
							<?php
								echo $styleList;
							?>	 
						</select></td>
						<td width="100" class="label">Đặc trưng đề tài</td>
					   <td class="content"> <select name="cboPropertyTopic" id="cboPropertyTopic" class="box">
						<option value="0" selected>-- Đặc trưng đề tài --</option>
							<?php
								echo $proList;
							?>	 
						</select></td>
				  </tr>
				  <tr>
				  	<td class="label">Nội dung đề tài</td>
					<td class="content">
						<input id="uploadFiles" name="uploadFiles[]" type="file" class="multi" maxlength="10"/>
					</td>
				  </tr>
				  <tr>
				  		<td width="150" class="label">Quốc gia</td>
					<td class="content" colspan="3"> <select name="cboCountry" id="cboCountry" class="box">
						 <option value="0" selected>-- Chọn quốc gia --</option>
								<?php
									echo $countryList;
								?>	 
						</select></td>
				  </tr>
				  <tr>
				  	<td width="150" class="label">Trường</td>
					 <td class="content"> <select name="cboSchool" id="cboSchool" class="box">
					   <option value="" selected>-- Chọn trường --</option>
							<?php
								echo $list;
							?>	 
					   </select>
				 		</td>
				  </tr>
				  <tr>
				  		 <td class="label">Đơn vị</span></td>
					   
						   <td class="content" colspan="5"> <select name="cboDept" id="cboDept" class="box">
						<option value="" selected>-- Chọn đơn vị --</option>
							<?php
								echo $deptList;
							?>	 
						</select> </td>
				  </tr>
				  <tr>
						<td colspan="7">
							 <div class="header"><span>Người thực hiện đề tài</span>
						</td>
				  </tr>
		   <tr>
			   <td width="150" class="label">Quốc gia</td>
					<td class="content" colspan="3"> <select name="cboCountry1" id="cboCountry1" class="box">
						 <option value="0" selected>-- Chọn quốc gia --</option>
								<?php
									echo $countryList;
								?>	 
						</select></td>
				</tr>
				<tr>
					<td width="150" class="label">Trường</td>
					 <td class="content" colspan="3"> <select name="cboSchool1" id="cboSchool1" class="box">
					   <option value="" selected>-- Chọn trường --</option>
							<?php
								echo $list;
							?>	 
					   </select>
				 </td>
				</tr>
				 <tr>
				  		 <td class="label">Đơn vị</span></td>
					   
						   <td class="content" colspan="5"> <select name="cboDept1" id="cboDept1" class="box">
						<option value="" selected>-- Chọn đơn vị --</option>
							<?php
								echo $deptList;
							?>	 
						</select> </td>
				  </tr>
				  <tr>
						 <td class="label">Tên người thực hiện</span></td>
						 <td align="left" class="content" colspan="5"> <select name="cboAuthor-Topic" id="cboAuthor-Topic" class="box">
								<option value="0" selected>-- Chọn tên người thực hiện --</option>
									<?php
										//echo $list;
									?>	 
								</select>&nbsp;&nbsp;&nbsp;&nbsp;Vai trò&nbsp;&nbsp;&nbsp;&nbsp;<select name="cboAuthorRoleTopic" id="cboAuthorRoleTopic" class="box">
								<option value="0" selected>-- Chọn vai trò --</option>
									<?php
										echo $roleList;
									?>	 
								</select><input  align="left" size="20" name="btnAddPerson" type="button" id="btnAddPeson" value="Thêm người thực hiện" onclick="appendRow()"class="box"> 
						</td>
					 </tr>
				 </table>
				<table id="tbl_nth" width="100%" id="t1" border="1" align="center" cellpadding="2" cellspacing="1"  class="data" >
					  <!--<tr align="center" id="listTableHeader">-->
					 <tr> 
						  <th width="0%" style="display:none"></th>
						  <th width="0%" style="display:none"></th>
						  <th width="50%">Tên người thực hiện</th>
						  <th width="40%">Vai trò</th>
						  <th width="10%">Loại bỏ</th>
					</tr>	
				  </table>
				  <br />
				  <br />
				 <p align="center"> 
				  <input name="btnAddTopic" type="button" id="btnAddTopic" value="Thêm đề tài" onClick="checkAddTopicForm(true);" class="box">
				  &nbsp;&nbsp;<input name="btnCancel" type="button" id="btnCancel" value=" Hủy " onClick="window.location.href='index.php';" class="box">  
				 </p>
				</form>
		</div>
	</div>

